package com.hr.reactive.operators;

import com.hr.reactive.common.Utils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Optional;

/**
 * @author Administrator
 */
public class Lec06DefaultIfEmpty {
    public static void main(String[] args) {
        Mono.just("23").filter(i->i.length()>23).defaultIfEmpty("fallback")
                .subscribe(Utils.subscriber());

        Flux.range(1,10)
                .filter(i->i>10)
                .switchIfEmpty(fallback())
                .subscribe(Utils.subscriber());


    }

    private static Flux<Integer>fallback(){
        return Flux.range(100,3);
    }
}
